﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GG.Business
{
    public class TaskManager
    {
        public static Task PerformForSimplexMethod(Task task)
        {
            return task;

            var newTask = new Task();

            newTask.VariablesCount = task.VariablesCount;
            newTask.IsMinimized = true;
            foreach (var item in task.GoalFunctionCoefficients)
            {
                newTask.GoalFunctionCoefficients.Add(item * (task.IsMinimized ? 1 : -1));
            }

            foreach (var item in task.Restrictions)
            {
                var restriction = new TaskRestriction();

                int coef = item.C <= 0 ? -1 : 1;

                restriction.C = item.C * coef;
                restriction.ComparisonSign = item.ComparisonSign * coef;
                foreach (var coefficient in item.Coefficients)
                {
                    restriction.Coefficients.Add(coefficient * coef);
                }

                newTask.Restrictions.Add(restriction);
            }

            return newTask;
        }
    }
}
